using System;
using System.Collections.Generic;
using System.Text;

namespace Pixysoft
{
    public class NumberCoder
    {
        private static NumberCoder instance;
        public static NumberCoder Instance
        {
            get
            {
                lock (typeof(NumberCoder))
                {
                    if (instance == null)
                        instance = new NumberCoder();
                    return instance;
                }
            }
        }

        public int CeilingToInt(string value)
        {
            double dvalue;

            if (!double.TryParse(value, out dvalue))
                return 0;

            dvalue = Math.Ceiling(dvalue);

            return (int)dvalue;
        }

        public Int64 CeilingToInt64(string value)
        {
            double dvalue;

            if (!double.TryParse(value, out dvalue))
                return 0;

            dvalue = Math.Ceiling(dvalue);

            return (Int64)dvalue;
        }

        public bool IsInt64(string value)
        {
            Int64 rvalue = Int64.MinValue;

            return Int64.TryParse(value, out rvalue);
        }

        public string To16Base(int value)
        {
            return Convert.ToString(value, 16);
        }

        private void test()
        {
            Console.Write(CeilingToInt("3.11"));
        }

    }
}
